<%= form_for @user, url: {action: @url} do |f| %>
  <h3>Benutzerdetails</h3>
  
  <table>
  <tr>
  	<td rowspan="4"> 		
  		<% paintings = Painting.where(:user_id => @user.id)
    	   if paintings.count == 1
    	   	painting = paintings[0]
    	   else
    	   	painting = nil
    	   end
    	%>
    	<% if !painting.nil? and painting.image? %>
 			<%= image_tag(painting.image_url, :id => "avatar", :alt => "Avatar", :class => "avatar") %>
 		<% else %>
 			<%= image_tag("layout/user.png", :id => "avatar", :alt => "Kein Avatar Verfügbar", :class => "avatar") %>
 		<% end %>
 	</td>
  </tr>
  <tr>
  	<td>
	    <%= f.label :name %>:
	</td>
	<td>
	    <% if @url=="update" %>
	    <%= f.text_field :name, :disabled => true %>
	    <% else %>
	    <%= f.text_field :name %>
	    <% end %>
	</td>
  </tr>
  <tr>
	 <td>
	    <%= f.label :email %>:
	 </td>
	 <td>
	    <% if @url=="update" %>
	    <%= f.text_field :email, :disabled => true %>
	    <% else %>
	    <%= f.text_field :email %>
	    <% end %>
	 </td> 
  </tr>
  <tr>
  	<td></td>
  	<td></td>
  </tr>
  </table>
  
  <div class="project_assignment">
  	<table class="assignment" id="assignment_table">
  		<thead>
	  		<tr>
	  			<th>
	  				Projekt
	  			</th>
	  			<th>
	  				Rolle
	  			</th>	
	   			<th>
	   				Anteil
	  			</th>			  					
	  		</tr>
  		</thead>
  		<tbody>
  		</tbody>
  	</table>
  </div>
  <%
  @text = "Benutzer anlegen"
  if @url=="update"
  	@text = "Benutzer aktualisieren"
  end 
  %>
  <div id="buttons">
  	<input type="hidden" id="user_id" value="ma_<%= @user.id%>">
  	<input type="button" class="user_button" id="add_assignment" value="Weitere Zuordnung">
  	<input type="button" class="user_button" id="<%=@url%>_user" value="<%= @text %>">
  </div>
<% end %>

